package comp302.prototype.slide;

import javax.swing.JPanel;
import javax.swing.border.LineBorder;
import java.awt.Color;
import javax.swing.JLabel;
import javax.swing.SwingConstants;

import comp302.prototype.MainWindow;

import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

public class PreviewItem extends JPanel {
	private static final long serialVersionUID = 852824750384724184L;
	
	private final int number;

	public PreviewItem(int num) {
		JLabel idLabel = new JLabel(Integer.toString(num));
		number = num;
		
		setFocusable(true);
		setBackground(Color.WHITE);
		setBorder(new LineBorder(new Color(0, 0, 0)));
		setLayout(new BorderLayout(0, 0));
		idLabel.setFont(new Font("Lucida Grande", Font.PLAIN, 28));
		idLabel.setHorizontalAlignment(SwingConstants.CENTER);
		add(idLabel);

		addMouseListener(new MouseListener() {

			@Override
			public void mouseClicked(MouseEvent e) {
				requestFocus();
				MainWindow.getSlideController().show(number);
			}

			@Override
			public void mouseEntered(MouseEvent e) {
			}

			@Override
			public void mouseExited(MouseEvent e) {
			}

			@Override
			public void mousePressed(MouseEvent e) {
			}

			@Override
			public void mouseReleased(MouseEvent e) {
			}
		});
	}
}
